
export const createPromise = (value) => {
  return new Promise(resolve => {
    return resolve(value)
  })
}

export const createfactories = (value, wait) => () => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(value)
    }, wait)
  })
}

// 延迟执行，返回promise实例。
export const timeout = (ms, value) => {
  return new Promise(resolve => {
    setTimeout(resolve, ms, value)
  })
}

export const loadimgAsync = (url) => {
  // debugger
  return new Promise((resolve, reject) => {
    const img = new Image(100, 100)
    img.src = url
    img.onload = () => {
      resolve(img)
    }
    img.onerror = () => {
      reject()
    }
  })
}
